<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="img/favicon.ico">

    <title>Signin Template for Bootstrap</title>
    <?php include 'includes/header.php'; ?>
    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/signin.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <div class="container">

<!--       <form class="form-signin" > -->
        <h2 class="form-signin-heading">Please sign in</h2>
        <input type="text" id="userName" class="form-control" placeholder="Email address" required autofocus>
        <input type="password" id="passWord" class="form-control" placeholder="Password" required>
        <label class="checkbox">
          <input type="checkbox" value="remember-me"> Remember me
        </label>        
        <button id="authentifier" class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<!--        </form> -->
                              
    </div> <!-- /container -->
<!--     <table id="result"></table>   -->
	<script type="text/javascript">
	
	$('#authentifier').click(function(){
		var values={
			"functionName" : 'authentification',                        
			"userName"     : $("#userName").val(),
			"passWord"     : $("#passWord").val(),		
	};
             //alert(values.passWord);
             
	$.ajax({
			url : "Controller.php",
			data : values,
			type : 'POST',
			success : function(response){
				$('#result').html(response.id);
				  if(response.id==1)
				  {
					     window.location = 'showCalender.php'; 
				  }else
				  {
					     alert('Authentication failed try again :)');
					     window.location ='index.php';
				  }					
			},
			error : function(errorObject){ 
				$('#result').html(errorObject.responseText);					
			}
		});
	});
	
	</script>
  </body>
</html>
